Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

845
Visualizações
Paperclip gem Rails [6.1] : migration error wrong number of arguments (given 3, expected 2)

Im trying to install paperclip gem on my rails app and I had 3 problems in succession and I would like to point out to them, it may be related to the last problem :

1- I coulden't install the paperclip dependency "mimemagic" => I solved it by adding the file freedesktop.org.xml.in and its variable FREEDESKTOP_MIME_TYPES_PATH to my windows machine.

2 - Then after initializing paperclip I couldn't do the migration => I solved it by adding the version of my rails app which is [6.1] bessid the Active record so it become class AddAttachmentImageToPics < ActiveRecord::Migration[6.1].

3- The last problem which Im stuck in is when I type rails db:migrate I get this message that says :

ArgumentError: wrong number of arguments (given 3, expected 2)

This is the content of my migration file :

class AddAttachmentImageToPics < ActiveRecord::Migration[6.1]
  def self.up
    change_table :pics do |t|
      t.attachment :image
    end
  end

  def self.down
    remove_attachment :pics, :image
  end
end

the message in cmd :

C:\Users\Admin\Desktop\Ruby\instagrameme>rails db:migrate
== 20220205102326 AddAttachmentImageToPics: migrating =========================
-- change_table(:pics)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (given 3, expected 2)
C:/Users/Admin/Desktop/Ruby/instagrameme/db/migrate/20220205102326_add_attachment_image_to_pics.rb:4:in `block in up'
C:/Users/Admin/Desktop/Ruby/instagrameme/db/migrate/20220205102326_add_attachment_image_to_pics.rb:3:in `up'

Caused by:
ArgumentError: wrong number of arguments (given 3, expected 2)
C:/Users/Admin/Desktop/Ruby/instagrameme/db/migrate/20220205102326_add_attachment_image_to_pics.rb:4:in `block in up'
C:/Users/Admin/Desktop/Ruby/instagrameme/db/migrate/20220205102326_add_attachment_image_to_pics.rb:3:in `up'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I think this is the root cause of your issue. The column method used took 3 arguments in rails 5, but the 3rd argument got changed to a keyword argument in rails 6. This is an issue for ruby >= 2.7 because they removed automatic conversion of a hash to keyword arguments.

You would probably need to fork or monkey patch paperclip to fix this issue.

over 4 years ago · Santiago Trujillo Relatório

0

@santiago I'm a total newbie and it seems I have the same issue, although I am on a mac. Any help you can please provide on how to fork or monkey patch paperclip?
- Kevin

about 4 years ago · Kevin Fahy Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda